<template>
	<view class="contents" :style="'height:'+screenHeight+'px'">
		<view class="herder">
			<view class="headerchildren">
				<view class="date-tabs-container">
					<view class="calendar-button color1">
						<u-icon name="calendar" size="65"></u-icon>
					</view>
					<view class="tabs-wrapper">
						<view class="span" v-for="(item,index) in list1" :key="index" @click="count(item.fullday,index)"
							:class="{color1blod : index === countindex}">
							<span class="spans">{{item.week}}</span>
							<span class="spans">{{item.day}}</span>
						</view>
					</view>

				</view>
			</view>
		</view>

		<view class="content">
			<view class="none" v-if="show==false">
				<view class="coent">
					<u-empty text="当日暂无排班" mode="data" icon="/static/zwnr.png" icon-size="200">
					</u-empty>
				</view>
			</view>
			<view class="shows" v-else>
				<view class="showlist" v-for="(doctor,index) in doctorinfor" :key="index"
					@click="situation(doctor)">
					<view class="imglist">
						<view class="imgleft">
							<u-avatar :src="'data:image/jpeg;base64,'+doctor.HeadImg" size='150'></u-avatar>
						</view>
						<view class="imgcount">
							<span class="name">{{doctor.DoctorName}}</span>
							<span class="describe">职称：{{doctor.WorkType}}</span>
							<span class="describe">擅长：{{doctor.WorkDuty}}</span>
						</view>
						<view class="imgright">
							<view class="excessive bacnone2" v-if="doctor.Status==1"><span>有号</span></view>
							<view class="excessive gray" v-else><span>无号</span></view>
						</view>

					</view>
					<!-- <u-divider></u-divider> -->
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	//import DateTabs from '@/uni_modules/hope-11-date-tabs/components/hope-11-date-tabs/date-tabs.vue'
	export default {
		data() {
			return {
				screenHeight: getApp().globalData.screenHeight - 44,
				show: false,
				countindex: 0,
				doctorinfor: [],
				list: [{
					name: '待收货'
				}, {
					name: '待付款'
				}, {
					name: '待评价'
				}],
				list1: [],
				DepartmentId: ''
			}
		},
		created() {

		},
		mounted() {

		},
		onLoad: function(option) {
			//console.log(DepartmentId)
			// uni.showLoading({
			// 	title: '加载中'
			// })
			this.DepartmentId = option.DepartmentId
			this.gettime()
			return

			// this.getCurrentAndNextWeekDates()
		},
		computed: {

		},
		methods: {
			gettime() {
				this.$request('HisDuty', 'DutyWeek').then(res => {
					if (res.code == 1) {
						console.log("ressss", res)
						this.list1 = res.data
						// let list = this.list1
						// for (let i = 0; i < list.length; i++) {
						// 	this.list1[i].name = `` + list[i].week + `\n` + list[i].day + ``
						// }
						this.content()
					} else {
						uni.hideLoading();
						console.log("获取失败")
					}
				})
			},
			getCurrentAndNextWeekDates() {
				const currentDate = new Date();
				const weekDates = [];

				for (let i = 0; i <= 7; i++) {
					const year = currentDate.getFullYear();
					const month = currentDate.getMonth() + 1;
					const date = currentDate.getDate();
					const dayOfWeek = currentDate.getDay();
					weekDates.push({
						year,
						month,
						date,
						dayOfWeek: ['周日', '周一', '周二', '周三', '周四', '周五', '周六'][dayOfWeek],
					});
					currentDate.setDate(currentDate.getDate() + 1);
				}

				console.log("weekDates", weekDates)
			},

			count(fullday,index) {
				uni.showLoading({
					title: '加载中'
				})
				this.countindex=index
				console.log("fulldayindex",fullday)
				this.$request('HisDuty', 'Dutylist', {
					dptid: this.DepartmentId,
					pbtime: fullday
				}).then(res => {
					if (res.code == 1) {
						console.log("科室", res)
						this.doctorinfor=[]
						this.doctorinfor = res.data
						uni.hideLoading();
						if (this.doctorinfor.length == 0) {
							this.show = false
							return
						} else {
							this.show = true
						}
					} else {
						uni.hideLoading();
						console.log("获取失败")
					}
				})
			},
			situation(doctor) {
				console.log("doctor",doctor)
				uni.navigateTo({
					url: `/pages/register/situation/situation?DutyId=${doctor.hispbid}&DoctorId=${doctor.DoctorId}`,
					fail(error) {
						console.log(error)
					}
				})
			},
			content() {
				uni.showLoading({
					title: '加载中'
				})
				this.$request('HisDuty', 'Dutylist', {
					dptid: this.DepartmentId,
					pbtime: this.list1[0].fullday
				}).then(res => {
					if (res.code == 1) {
						console.log("科室", res)
						this.doctorinfor=[]
						this.doctorinfor = res.data
						uni.hideLoading();
						if (this.doctorinfor.length == 0) {
							this.show = false
							return
						} else {
							// this.countindex=this.doctorinfor[0].fullday
							this.show = true
						}
					} else {
						uni.hideLoading();
						console.log("获取失败")
					}
				})
				// console.log("123")
				// if (this.list1[0].ReturnDuty.length == 0) {
				// 	this.show = false
				// 	return
				// } else {
				// 	this.show = true
				// }
				// this.doctorinfor = []
				// this.doctorinfor = this.list1[0].ReturnDuty

			}
		}
	}
</script>

<style>
	@import './Scheduling.css'
</style>